package db;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;


public class DbManagerInDict {
 
    public static int insert(int userID, int dictID, int role) {
    	
    	Connection cnn = null;
        CallableStatement cstat = null;
        
        try {
            cnn = DbController.getConnection();
            cstat = cnn.prepareCall("{call m_managerindict_insert(?,?,?)}");
            cstat.setInt(1, userID);
            cstat.setInt(2, dictID);
            cstat.setInt(3, role);
            
            return cstat.executeUpdate();
        }
        
        catch (SQLException e) {
			// TODO: handle exception
        	return 0;
		}       
    }
    
    public static int update(int dictID, int role) {
    	
    	Connection cnn = null;
        CallableStatement cstat = null;
        
        try {
            cnn = DbController.getConnection();
            cstat = cnn.prepareCall("{call update_managerindict_role(?,?)}");
            cstat.setInt(1, dictID);
            cstat.setInt(2, role);
            
            return cstat.executeUpdate();
        }
        
        catch (SQLException e) {
			// TODO: handle exception
        	return 0;
		}       
    }
    
    public static int delete(int userID, int dictID) {
    	
    }
    
    public static int getManager(int dictID, int userID) {
    	
    }
}
